// 自定义序列化
export function serialize(obj) {
  const data = { ...obj };
  for (let key in data) {
    if (typeof data[key] === 'function') {
      data[key] = '__isFunction';
    }
  }
  return JSON.stringify(data);
}

// 自定义反序列化
export function deserialize(json, MyClass) {
  const data = JSON.parse(json);
  for (let key in data) {
    if (data[key] === '__isFunction') {
      data[key] = MyClass.prototype[key];
    }
  }
  return data;
}

// const obj = new MyClass();
// const serialized = serialize(obj);
// const deserialized = deserialize(serialized);